import { Body, Controller, Get, Param, ParseIntPipe, Post, Req } from '@nestjs/common';
import { WaterTestService } from './water-test.service';
import { ResponseUtilService } from '@app/response-util';
import { ReqAttrs } from '../../constant';

@Controller('waterTest')
export class WaterTestController {
    constructor(
        private readonly service:WaterTestService,
    ) {}


    @Post('test')
    async test(@Body('id', ParseIntPipe) id:number, @Req() req) {
        let rows = await this.service.test(id, req[ReqAttrs.USER_ID])
        return ResponseUtilService.successRes(rows)
    }

    @Post('page')
    async page(@Body() dto:Pagination, @Req() req) {
        let rows = await this.service.page(dto, req[ReqAttrs.USER_ID])
        return ResponseUtilService.successRes(rows)
    }

    @Get('data/:id')
    async data(@Param('id', ParseIntPipe) id:number, @Req() req) {
        const data = await this.service.data(id, req[ReqAttrs.USER_ID])
        return ResponseUtilService.successRes(data)
    }
}
